Skip to content

[codex] Detach image upstream context#3365

Draft
cyeinfpro wants to merge 1 commit into
Wei-Shaw:mainfrom
cyeinfpro:codex/detach-image-upstream-context
Draft

[codex] Detach image upstream context#3365
cyeinfpro wants to merge 1 commit into
Wei-Shaw:mainfrom
cyeinfpro:codex/detach-image-upstream-context

Conversation

@cyeinfpro

@cyeinfpro cyeinfpro commented Jun 19, 2026

Copy link
Copy Markdown

Summary

  • Detach OpenAI Images API-key upstream requests from the client request context.
  • Keep OAuth / Responses image forwarding behavior unchanged.
  • Add regression coverage for non-stream API-key image forwarding after the downstream context is canceled.

Why

For non-stream /v1/images/* requests routed through API-key accounts, the upstream request reused the downstream HTTP context. If the client or an intermediate proxy disconnected before upstream image generation completed, the gateway canceled the provider request with context canceled. The provider may already have accepted and billed the generation, but the gateway could no longer receive the successful image response.

Streaming image requests and the Responses/OAuth image path already use detached upstream contexts. This change makes API-key non-stream Images forwarding consistent with those flows.

Validation

go test ./internal/service -run 'TestOpenAIGatewayServiceForwardImages_APIKeyNonStreamDetachesUpstreamContext|TestOpenAIImages'\ngo test ./internal/handler -run 'Test.*Images|Test.*NoAccount'\n(cd backend && go test ./...)\n(cd frontend && pnpm test:run)\n```

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Before we can merge this PR, we need you to sign our Contributor License Agreement (CLA).

To sign, please reply with the following comment:

I have read the CLA Document and I hereby sign the CLA

You only need to sign once — it will be valid for all your future contributions to this project.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@cyeinfpro cyeinfpro force-pushed the codex/detach-image-upstream-context branch from 88a266f to 165ddc8 Compare June 19, 2026 02:21
@cyeinfpro cyeinfpro force-pushed the codex/detach-image-upstream-context branch from 007c7bf to e6dc8b0 Compare June 26, 2026 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant